package com.teacher.pojo.enums.items;

import java.math.BigDecimal;

public enum PunishmentType {
    /**
     * 10->留校查看处分
     * 20->记过处分
     * 30->严重警告处分
     * 40->警告处分
     * 50->通报批评
     */
    A(10, new BigDecimal("-20"), "留校查看处分"),
    B(20, new BigDecimal("-10"), "记过处分"),
    C(30, new BigDecimal("-8"), "严重警告处分"),
    D(40, new BigDecimal("-5"), "警告处分"),
    E(50, new BigDecimal("-1"), "通报批评");
    private Integer code;
    private BigDecimal grades;
    private String name;

    PunishmentType(Integer code, BigDecimal grades, String name) {
        this.grades = grades;
        this.code = code;
        this.name = name;
    }

    /**
     * 通过code拿到名称
     *
     * @param type
     * @return
     */
    public static String getNameByCode(Integer type) {
        for (PunishmentType eType : PunishmentType.values()) {
            if (eType.code.equals(type)) {
                return eType.name;
            }
        }
        return "0";
    }

    /**
     * 通过code拿到分数
     *
     * @param type
     * @return
     */
    public static BigDecimal getGradesByCode(Integer type) {
        for (PunishmentType eType : PunishmentType.values()) {
            if (eType.code.equals(type)) {
                return eType.grades;
            }
        }
        return new BigDecimal(0);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public BigDecimal getGrades() {
        return grades;
    }

    public void setGrades(BigDecimal grades) {
        this.grades = grades;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
